package edu.mercer.employmentcalculator;

public class Compensation
{
	public static int HoursInYear = 2088; // 261 weekdays/year * 8 hours/day
	
	private double _salary; // per year
	public double getSalary() { return _salary; }
	public void setSalary(double salary) { this._salary = salary; }
	public double getHourlyWage() { return _salary / HoursInYear; }
	public void setHourlyWage(double wage) { this._salary = wage * HoursInYear; }
	
	private int _vacation; // hours/year
	public int getVacationHours() { return _vacation; }
	public void setVacationHours(int hours) { this._vacation = hours; }
	public int getVacationDays() { return _vacation / 8; }
	public void setVacationDays(int days) { this._vacation = days * 8; }
	
	private int _holidays; // days/year
	public int getHolidayHours() { return _holidays * 8; }
	public void setHolidayHours(int hours) { this._holidays = hours / 8; }
	public int getHolidays() { return _holidays; }
	public void setHolidays(int days) { this._holidays = days; }
	
	private int _sick; // hours/year
	public int getSickHours() { return _sick; }
	public void setSickHours(int hours) { this._sick = hours; }
	public int getSickDays() { return _sick / 8; }
	public void setSickDays(int days) { this._sick = days * 8; }
	
	private double _coli;
	public double getColi() { return _coli; }
	public void setColi(double coli) { this._coli = coli; }
	
	public double CalculateEquivalentSalary()
	{
		return this.CalculateEquivalentHourlyWage() * HoursInYear;
	}
	
	public double CalculateEquivalentHourlyWage()
	{
		int annualWorkingHours = HoursInYear - this.getVacationHours() - this.getSickHours() - this.getHolidayHours();
		double totalAnnualPay = getTotalAnnualPay();
		return totalAnnualPay / annualWorkingHours;
	}
	
	public double getTotalAnnualPay()
	{
		return this.getSalary(); // TODO: add bonus, etc.
	}
	
	public void CalculateSalary(Compensation other, double raise)
	{
		other = other.Clone();
		other.setSalary(other.getSalary() + raise);
		double equivSalary = other.getSalary() * this.getColi() / other.getColi();
		// TODO: need to adjust for differences in paid days off...
		this.setSalary(equivSalary);		
	}
	
	public Compensation Clone()
	{
		Compensation clone = new Compensation();
		clone.setSalary(this.getSalary());
		clone.setVacationDays(this.getVacationDays());
		clone.setHolidays(this.getHolidays());
		clone.setSickDays(this.getSickDays());
		clone.setColi(this.getColi());
		
		return clone;
	}
}
